using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;
using DeepMixWorkflow;

namespace DeepmixRadioClient.Workflow
{
    public class NullOrZeroToVisibleConverter : IValueConverter
    {
        public bool checkDeepMix { get; set; }

        public bool ReturnBool { get; set; }

        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null) return ReturnBool ? (object) true : Visibility.Visible;

            var enumerable = value as IEnumerable<DeepMixTrack>;
            if (enumerable != null)
            {
                if (!((IEnumerable<DeepMixTrack>) value).Any())
                    return ReturnBool ? (object) true : Visibility.Visible;
            }
            return ReturnBool ? (object) false : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new InvalidOperationException();
        }

        #endregion
    }
}